package com.yodawnla.fishing.hud;

 
import com.yodawnla.fishing.R;
import com.yodawnla.fishing.system.Fonts;
import com.yodawnla.fishing.system.Tex;
import com.yodawnla.lib.YoActivity;
import com.yodawnla.lib.util.widget.YoButton;
import com.yodawnla.lib.util.widget.YoText;


public class YesNoWindow extends Window
{
	public static YesNoWindow getInstance()
	{
		if (instance == null)
			instance = new YesNoWindow();
		return instance;
	}
	
	YoText mOkBtnText;
	YoText mCancelBtnText;
	
	static YesNoWindow instance;
	YesNoWindow()
	{
		super(HudValues.Name.YesNoWindow, HudValues.ZIndex.YesNoWindow);
		
		YoButton button = new YoButton(mHudMgr.getHud(), 222, 166, YoActivity.getBaseActivity().getTexture(Tex.Button2))
		{
			public void init()
			{
				mOkBtnText = new YoText(20, 20, Fonts.White20,  YoActivity.getBaseActivity().getRString(R.string.Ok), 10);
//				mOkBtnText.setColor(0, 0, 0);
				mOkBtnText.setPosition((this.getWidth() - mOkBtnText.getWidth()) / 2, (this.getHeight() - mOkBtnText.getHeight()) / 2);
				this.attachChild(mOkBtnText);
			}
			
			public void onClickedEvent()
			{
				if (mListener != null)
					mListener.onOkClicked();
				hide();
			}
		};
		mWindow.attachChild(button);
		
		button = new YoButton(mHudMgr.getHud(), 50, 166, YoActivity.getBaseActivity().getTexture(Tex.Button2))
		{
			public void init()
			{
				mCancelBtnText = new YoText(20, 20, Fonts.White20,  YoActivity.getBaseActivity().getRString(R.string.Cancel), 10);
//				mCancelBtnText.setColor(0, 0, 0);
				mCancelBtnText.setPosition((this.getWidth() - mCancelBtnText.getWidth()) / 2, (this.getHeight() - mCancelBtnText.getHeight()) / 2);
				this.attachChild(mCancelBtnText);
			}
			
			public void onClickedEvent()
			{
				if (mListener != null)
					mListener.onCancelClicked();
				hide();
			}
		};
		mWindow.attachChild(button);
	}
	
	public void show(String text)
	{
		show(text, null);
	}
	
	public void show(String text, IButtonClickListener listener)
	{
		mOkBtnText.setText( YoActivity.getBaseActivity().getRString(R.string.Ok));
		mCancelBtnText.setText( YoActivity.getBaseActivity().getRString(R.string.Cancel));
		super.show(text, listener);
	}
	
	public void show(String text, String okBtnText, String cancelBtnText, IButtonClickListener listener)
	{
		mOkBtnText.setText(okBtnText);
		mCancelBtnText.setText(cancelBtnText);
		super.show(text, listener);
	}
	
	public void show(Param param)
	{
		mOkBtnText.setText(param.mOkBtnText);
		mCancelBtnText.setText(param.mCancelBtnText);
		super.show(param);
	}
}
